{% assign user = User | user_id | users_by_id %}

{% if User | is_in_role: "Hacker" %}
  {% if Site.Properties.HackathonCustomSettings.TeamCustomSettings.TeamEditable.Value == true and user.Properties.Hacker.Hacker.Team.ContentItemIds | first == null %}
    {% assign teams = Queries.GetItemsForHackathon | query: type: "Team" %}
    <v-container>
      <v-row justify="center">
        <v-col cols="8">
          <v-card>
            <v-card-title>{{ "Join a team" | t }}</v-card-title>
            <v-card-text>
              {% for team in teams %}
                {% assign h = Queries.GetHackersForTeam | query: teamContentItemId: team.ContentItemId %}
                {% if h.size < Site.Properties.HackathonCustomSettings.TeamCustomSettings.TeamSize.Value or Site.Properties.HackathonCustomSettings.TeamCustomSettings.TeamSize.Value == null %}
                  <div class="row">
                    <div class="col flex-start">{{team | display_text}}</div>
                        <form method="post" action="{{ "~/team/join" | href }}">
                          <v-btn type="submit">{{ "Join" | t }}</v-btn>
                          {% antiforgerytoken %}
                          <input type="hidden" name="returnUrl" value="{{Model.Dashboard.Content.AutoroutePart.Path}}">
                          <input type="hidden" name="teamContentItemId" value="{{team.ContentItemId}}">
                        </form>
                    </div>
                    <div class="row">
                      {% if Site.Properties.HackathonCustomSettings.TeamCustomSettings.TeamSize.Value != null %}
                        <div class="flex-start">{{h.size}}/{{ Site.Properties.HackathonCustomSettings.TeamCustomSettings.TeamSize.Value }}</div>
                      {%endif%}  
                    </div>
                  {%endif%}       
              {% endfor %}
            </v-card-text>
          </v-card>
        </v-col>
      </v-row>
    </v-container>
  {% endif %}
{% endif %}